🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@temporalio/workflow

Package Overview
Dependencies
Maintainers
7
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/workflow

Temporal.io SDK Workflow sub-package

1.11.8
latest
Source
npm
Version published
Weekly downloads
345K
-16.27%
Maintainers
7
Weekly downloads
 
Created

What is @temporalio/workflow?

@temporalio/workflow is a package for building and managing workflows using Temporal, a microservices orchestration platform. It allows developers to write workflows in a straightforward and maintainable way, handling complex state management, retries, and timeouts.

What are @temporalio/workflow's main functionalities?

Defining a Workflow

This feature allows you to define a workflow using the `defineWorkflow` function. The workflow logic is written as an async function, making it easy to manage asynchronous operations.

const { defineWorkflow } = require('@temporalio/workflow');

const myWorkflow = defineWorkflow(async function() {
  // Workflow logic here
  console.log('Workflow started');
  await someActivity();
  console.log('Workflow completed');
});

Executing Activities

Activities are the building blocks of workflows. This feature allows you to define activities that can be executed within a workflow. Activities can perform tasks such as calling external services or processing data.

const { defineActivity } = require('@temporalio/workflow');

const someActivity = defineActivity(async function() {
  // Activity logic here
  return 'Activity result';
});

Handling Workflow State

Temporal workflows can maintain state across different steps. This feature allows you to set and get state within a workflow, making it easier to manage complex workflows with multiple steps.

const { defineWorkflow, setState, getState } = require('@temporalio/workflow');

const myWorkflow = defineWorkflow(async function() {
  setState('step', 1);
  console.log('Step 1');
  await someActivity();
  setState('step', 2);
  console.log('Step 2');
  await anotherActivity();
  console.log('Workflow completed');
});

Retrying Failed Activities

Temporal provides built-in support for retrying failed activities. This feature allows you to specify retry policies for activities, ensuring that transient failures are automatically retried.

const { defineActivity } = require('@temporalio/workflow');

const someActivity = defineActivity(async function() {
  // Activity logic here
  throw new Error('Activity failed');
}, { retry: { maximumAttempts: 3 } });

Other packages similar to @temporalio/workflow

Keywords

temporal

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts